#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void* a, const void* b)
{
	return (*(int*)a - *(int*)b);
}

int main()
{
	int n, k, i;
	scanf("%d %d", &n, &k);

	int num[10001];
	for (i = 0; i < n; i++)1
	{
		scanf("%d", &num[i]);
	}

	qsort(num, n, sizeof(num[0]), compare_int);

	for (int i = 0; i < k; i++) 
	{
		printf("%d ", num[i]);
	}

	return 0;
}